<?php
// Home Template - Blog Listing
$posts = get_posts();
?>

<?php include __DIR__ . '/header.php'; ?>

    <main>
        <?php foreach ($posts as $post): ?>
            <article>
                <h2><?= htmlspecialchars($post['title']) ?></h2>
                <div class="post-preview">
                    <?= htmlspecialchars_decode(substr(strip_tags($post['content']), 0, 200)) ?>...
                </div>
                <a href="/?route=post&file=<?= urlencode($post['filename']) ?>">Read More</a>
            </article>
        <?php endforeach; ?>
    </main>

    <footer>
        <p>&copy; <?= date('Y') ?> Codeless Blog</p>
    </footer>
</body>
</html>
